﻿@{
    Layout = null;
}
@model Domain.SYS_USER
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台登录</title>
    <link href="/Content/css/login/login.css" rel="stylesheet" />
</head>
<body>
    <section class="login">
        <div class="login_logo">
            <img src="/Content/images/login/login_top_tip.png" />
        </div>
        <div>
            @using (Ajax.BeginForm("login", null, new AjaxOptions()
            {
                HttpMethod = "Post",
                OnBegin = "dig.Loading",
                OnSuccess = "dig.Success",
                OnFailure = "dig.Failure",
                OnComplete = "dig.Complete"
            }, new { @class = "form-signin" }))
            {
                @Html.AntiForgeryToken()
                @Html.TextBoxFor(model => model.ACCOUNT,
                                                        new
                                                        {
                                                            @class = "form-control",
                                                            @placeholder = "登录用户名",
                                                            @maxlength = 15,
                                                            @required = "required"
                                                        })
                @Html.PasswordFor(model => model.PASSWORD,
                                                        new
                                                        {
                                                            @class = "form-control",
                                                            @placeholder = "登录密码",
                                                            @maxlength = 12,
                                                            @required = "required"
                                                        })

                <div class="from-control">
                    @Html.TextBox("code", "",
                                                        new
                                                        {
                                                            @class = "form-control",
                                                            @placeholder = "请输入验证码",
                                                            @datatype = "*",
                                                            @nullmsg = "请输入验证码！",
                                                            @maxlength = 4,
                                                            @required = "required",
                                                            @autocomplete = "off"
                                                        })
                    <div class="code-img">
                        <img id="imgVerify" src="/Sys/Account/ValidateCode" alt="看不清？点击更换" onclick="this.src = this.src + '?'" style="vertical-align:middle;" />
                    </div>
                </div>
                <div class="login_fields_submit">
                    <button type="submit" id="login-button">登录</button>
                </div>

            }

        </div>
    </section>
    <script src="/Scripts/jquery-1.10.2.min.js"></script>
    <script src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script>

        var dig = {
            Loading: function () {
                $("#login-button").attr("disabled", "disabled");;
            },
            Success: function (result) {
                if (result.Status == "y") {
                    alert(result.Msg);
                } else {
                    alert(result.Msg);
                    dig.Complete();
                }
            },
            Failure: function () {
                alert(result.Msg);
                dig.Complete();
            },
            Complete: function () {
                $("#login-button").attr("disabled", false);
            },
            ErrorMsg: function (msg) {
                alert(msg);
            }
        };
    </script>

</body>
</html>